package com.shd.edanpei.ui.activity;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.widget.EditText;
import android.widget.TextView;

import com.shd.edanpei.R;
import com.shd.edanpei.base.BaseActivity;
import com.shd.edanpei.common.Constant;
import com.shd.edanpei.presenter.contract.PhoneResetContract;
import com.shd.edanpei.presenter.PhoneResetPresenter;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Created by mc on 2018/6/1.
 * <p>
 * 修改手机号 第2步：填写验证码
 */

public class PhoneReset2Activity extends BaseActivity<PhoneResetPresenter>
        implements PhoneResetContract.PhoneResetIView {

    @BindView(R.id.headline)
    TextView headline;
    @BindView(R.id.tv_phone_reset2_phone)
    TextView tvPhone;
    @BindView(R.id.et_phone_reset2_code)
    EditText etCode;

    private String mPhone;

    @Override
    protected int setLayout() {
        return R.layout.phone_reset2_activity;
    }

    @Override
    protected PhoneResetPresenter bindPresenter() {
        return new PhoneResetPresenter(this);
    }

    @Override
    protected void initView(@Nullable Bundle savedInstanceState) {
        mPhone = getIntent().getExtras().getString(Constant.PHONE);
        headline.setText("填写验证码");
        tvPhone.setText(mPhone);
    }

    @Override
    protected void initListener() {

    }

    @OnClick(R.id.iv_headline_back)
    void close(){
        finish();
    }



    @OnClick(R.id.tv_phone_reset2_getcode)
    void getCode() {
        mPresenter.getCode(mPhone);
    }

    @OnClick(R.id.tv_phone_reset2_submit)
    void submit() {
        if (etData(etCode)) {
            mPresenter.submit(mPhone, etCode.getText().toString());
        }
    }
}
